//
//  MYShopSalesOrderAddressCell.swift
//  MuYing
//
//  Created by tbb on 2019/7/30.
//  Copyright © 2019 TBB. All rights reserved.
//

import UIKit

class MYShopSalesOrderAddressCell: YQTableViewBaseCell {

    @objc var addressModel = YQPAddressEntityModel()
    
    @IBOutlet weak var userNameLb: UILabel!
    
    @IBOutlet weak var phoneLb: UILabel!
    @objc @IBOutlet weak var rightBtn: UIButton!
    
    @IBOutlet weak var addressLb: UILabel!
    
    lazy var tagImage: UIImage = {
        let tagLb = UILabel();
        tagLb.frame = CGRect(x: 0, y: 0, width: 30, height: 12)
        tagLb.text = kYQLSSwift("默认");
        tagLb.textAlignment = .center;
        tagLb.textColor = appThemeColor;
        tagLb.font = UIFont.systemFont(ofSize: 11);
        tagLb.layer.borderWidth = 1;
        tagLb.layer.borderColor = appThemeColor.cgColor;
        tagLb.layer.cornerRadius = 3;
        tagLb.clipsToBounds = true;
        //imageWithUIView
        //UIImage.qmui_image(with: tagLb)
        
        if let image = UIImage.qmui_image(with: tagLb) {
            return image;
        }
        
        return UIImage();
    }()
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        self.rightBtn.setTitle(kYQLSSwift("选择"), for: .normal);
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        // Configure the view for the selected state
    }
    
    @objc func setModel(_ model:YQPAddressEntityModel){
        self.addressModel = model
//        UIImage.qmui_image(with: <#T##UIView#>) stringWithUIImage
        
        self.userNameLb.text = kYQLSSwift(String(model.surname) + String(model.name));
        self.phoneLb.text = model.userPhone;
        let addStr = kYQLSSwift(String(model.province)) + String(model.city) + String(model.userAddress);
        
        if model.isDefault {
            self.addressLb.attributedText = NSString.string(withUIImage: String(format: "%@%@", " ",addStr), image: self.tagImage, rect: CGRect(x: 0, y: -2, width: 30, height: 12))
        }else{
            self.addressLb.text = addStr;
        }
        //kYQLSSwift(String(model.province) + String(model.city) + String(model.userAddress));
//        self.rightBtn.addTarget(self, action: Selector(("editClick:")), for: .touchUpInside)
    }

}


